CyberMinds Logo

Course 6 - Explore Sudo

In this activity, we will look at an example of using sudo in a command and we will also look at the sudoers file.

Sudo Command

We will run the apt update command in order to update outdated packages Linux. For now, just think of it as updating Linux. From the terminal in Linux, type in “apt update”.

Unfortunately, this does not work and we get this message:

We see that we do not have permission to run this command. We need to escalate our privileges! Type the same command with “sudo” in front of it.

Great! It works. Using sudo gave you temporary permissions to run the apt update command. You should see this message:

The Sudoers File (Optional)

Just for fun, let’s navigate to the sudoer’s file! Since we have not learned about navigating the filesystem yet, we will provide all the commands you need to input (the commands will be in parentheses). If you want, you can look at the next article first and come back to this activity later.

  1. Navigate to the /etc directory (cd /etc).
  2. If you scroll around, you will see that “sudoers” is in this directory. This is the sudoer’s file. View its file contents (cat sudoers).
  3. Our permission is denied. What should we do to get around this? That’s right, sudo! View the file contents using sudo (sudo cat sudoers).

Congrats, you are looking at the sudoers file!